/*
 * 10. Write a program for finding all prime numbers
 * in the range [1..n] (n is read from the
 * console).
 */

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
	ArrayList<Integer> primes = new ArrayList<Integer>();
	Scanner scn = new Scanner (System.in);
	int n = 0;

	System.out.print ("n ?= ");
	if (scn.hasNextInt ())
	    n = scn.nextInt ();
	else {
	    System.err.println ("error: mismatched input");
	    System.exit (1);
	}

	primes.add (2);
	for (int i = 3; i <= n; i++) {
	    boolean prime = true;

	    for (int e : primes)
		if (i % e == 0) {
		    prime = false;
		    break;
		}

	    if (prime)
		primes.add (i);
	}

	for (int e : primes)
	    System.out.printf ("%d ", e);
	System.out.println();
    }
}
